package com.adingxiong.quickstart.project.mapper;

import com.adingxiong.quickstart.project.entity.vo.EchartVo;
import com.adingxiong.quickstart.project.entity.vo.HomeCountVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @ClassName EchartMapper
 * @Description TODO
 * @Author xiongchao
 * @Date 2020/6/11 10:53
 **/
public interface EchartMapper extends BaseMapper {


    /**
     * 查询指定时间类的网站访问数和固件下载数
     * @param startDate
     * @param endDate
     * @return
     */
    @Select(value = "select sum(viewc_count) as viewCount ,sum(upload_count) as uploadCount," +
            "DATE_FORMAT(create_time,'%Y-%m-%d') as date from sys_log where" +
            " DATE_FORMAT(create_time,'%Y-%m-%d') >= #{startDate} " +
            "and DATE_FORMAT(create_time,'%Y-%m-%d') < #{endDate}" +
            "GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY date  ")
    List<EchartVo> countGroupByDate(@Param("startDate") String startDate,@Param("endDate") String endDate);


    @Select(value = "select a.*,b.* from " +
            "(" +
            "SELECT" +
            " sum(viewc_count) AS viewCount," +
            " sum(upload_count) AS uploadCount" +
            " FROM" +
            " sys_log" +
            ") a," +
            " (" +
            "SELECT" +
            " count(1) AS emailCount" +
            " FROM" +
            " email_log" +
            ") b")
    HomeCountVo getTotal();

}
